08. Deploy and Test

Now that you have emojify written in your functions/index.js file, let's deploy it to Google Cloud Platform and see it in action.

Make sure that the index.js file is saved first in the text editor.

On the command line, while in the project directory (either the root directory like FriendlyChatFunctions or the FriendlyChatFunctions/functions subdirectory), run the command

$ firebase deploy

You'll see output similar to above when running `firebase deploy`

You'll see output similar to above when running firebase deploy

This command may take a while to complete. With this one command the Firebase SDK for Cloud Functions is packaging any functions in functions/index.js along with any dependencies declared in functions/package.json and deploying it to the cloud.

Once the deploy is complete, you'll be able to see details about the deployed function in the Firebase console in the Functions section, including the name, service, conditions, number of executions, median run time, and the logs.

Information on deployed functions is visible in the console

Information on deployed functions is visible in the console

Any time you want to update a cloud function, you can deploy your changes again with firebase deploy. Any modified functions will be updated and any functions you delete in the file will be removed from your Firebase project.

Test function in the Firebase console

In FriendlyChat, you can write new messages to the database in the Firebase console and see the results after the cloud function triggers. New messages for the path /messages/{pushId}/text will trigger the event (remember, path segments with braces are wildcards). So if you create a new message in that path with the value "Lol that cat is funny," you will see it changed to "😂 that 😸 is funny", like in the screenshots below:

Firebase console - New chat message **before** emojify function triggered

Firebase console - New chat message before emojify function triggered

Firebase console - Changed chat message **after** emojify function triggered

Firebase console - Changed chat message after emojify function triggered

Test function in Firebase console

Task List:

Task Feedback:

Nice work! 👍